Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rollup/plugin-alias

Package Overview
Dependencies
Maintainers
4
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rollup/plugin-alias

Define and resolve aliases for bundle dependencies

  • 5.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created

What is @rollup/plugin-alias?

@rollup/plugin-alias is a Rollup plugin that allows you to create custom module aliases, making it easier to manage and resolve module paths in your project. This can be particularly useful for simplifying import statements and avoiding relative path hell.

What are @rollup/plugin-alias's main functionalities?

Basic Alias Configuration

This feature allows you to define basic aliases for module paths. In this example, 'src' is aliased to './src' and 'components' is aliased to './src/components'. This simplifies import statements in your code.

{
  "plugins": [
    alias({
      entries: [
        { find: 'src', replacement: './src' },
        { find: 'components', replacement: './src/components' }
      ]
    })
  ]
}

Multiple Aliases

You can define multiple aliases to organize your project structure better. In this example, 'utils', 'assets', and 'config' are aliased to their respective directories.

{
  "plugins": [
    alias({
      entries: [
        { find: 'utils', replacement: './src/utils' },
        { find: 'assets', replacement: './src/assets' },
        { find: 'config', replacement: './src/config' }
      ]
    })
  ]
}

Regex Aliases

This feature allows you to use regular expressions for more complex aliasing. In this example, any import starting with '@components/' will be replaced with './src/components/'.

{
  "plugins": [
    alias({
      entries: [
        { find: /^@components\//, replacement: './src/components/' }
      ]
    })
  ]
}

Other packages similar to @rollup/plugin-alias

Keywords

FAQs

Package last updated on 22 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc